#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSerialPort>
#include <QSerialPortInfo>

#include "baseserialport.h"

QT_BEGIN_NAMESPACE

namespace Ui
{

    class MainWindow;

} // namespace Ui

QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
signals:
    void open(const QString &portName,
              QSerialPort::BaudRate baudRate,
              QSerialPort::DataBits dataBits,
              QSerialPort::Parity parity,
              QSerialPort::StopBits stopBits);
    void send(QByteArray data);
    void receive();
    void close();
private slots:
    void on_pushButtonGetPortList_clicked();

    void on_pushButtonOpenPort_clicked();

    void on_pushButtonClosePort_clicked();

    void on_pushButtonWriteData_clicked();

    void on_pushButtonReadData_clicked();

    void serialPortOpenResult(bool);

    void serialPortReceiveOK(QByteArray);

    void on_toolButtonChooseFile_clicked();

private:
    Ui::MainWindow *ui;
    BaseSerialport serialPort;
};
#endif // MAINWINDOW_H
